import QtQuick 1.1
import com.nokia.meego 1.0

Page {

    id: pagePairing
    lockInLandscape: true
    orientationLock: PageOrientation.LockLandscape


    //The background
    Image {
        id: background
        source: "images/pairingBg.png"
        x: 0
        y: 0
        z: -1
    }

    //Button for creating the game
    Image {
        id: button1
        source: "images/createbutton.png"
        opacity: 0.7 //The opacity is changed when pressed so that the user know that the touch is being detected
        anchors.centerIn: parent

        MouseArea {
            anchors.fill: parent
            onPressed: parent.opacity = 1 //When the user touches the button, it goes totally opaque...
            onReleased: parent.opacity = 0.7 //...But when released, it returns to the original opacity
            onClicked: {
                BluetoothManager.createServer();
                pagePairing.pageStack.push(appWindow.createPage);
            }
        }
    }

    //Button for joining the game
    Image {
        id: button2
        source: "images/joinbutton.png"
        opacity: 0.7 //The opacity is changed when pressed so that the user know that the touch is being detected
        anchors.top: button1.bottom
        anchors.horizontalCenter: parent.horizontalCenter

        MouseArea {
            anchors.fill: parent
            onPressed: parent.opacity = 1 //When the user touches the button, it goes totally opaque...
            onReleased: parent.opacity = 0.7 //...But when released, it returns to the original opacity
            onClicked: {
                BluetoothManager.createClient();
                pagePairing.pageStack.push(appWindow.joinPage);
            }
        }
    }

    //button to go back to the previous page
    Image {
        id: backButton
        source: "images/backButton.png"
        opacity: 0.7 //The opacity is changed when pressed so that the user know that the touch is being detected
        x: 0
        y: 0

        MouseArea {
            anchors.fill: parent
            onPressed: parent.opacity = 1 //When the user touches the button, it goes totally opaque...
            onReleased: parent.opacity = 0.7 //...But when released, it returns to the original opacity
            onClicked: pagePairing.pageStack.pop();
        }
    }
}
